const _ = require('lodash');

let _sites = [];
let _keywords = [];


function errorHandler(error) {

}

function setKeyword(keyword) {
    _keywords.push(keyword);
}

function setKeywords(keywords) {
    if (!Array.isArray(keywords)) {
        return;
    }
    for (const site of sites) {
        setKeyword(site);
    }

}

function getKeyword(keywordId) {
    return _.find(_keywords, keyword => keyword.id === keywordId);
}

function setSite(site) {
    _sites.push(site);
}

function getSite(siteId) {
    return _.find(_sites, site => site.id === siteId);
}

function setSites(sites) {
    if (!Array.isArray(sites)) {
        return;
    }
    for (const site of sites) {
        setSite(site);
    }
}

function setEmail(email) {

}

function getEmail(emailId) {

}


module.exports = {
    errorHandler,
    setKeyword,
    setKeywords,
    getKeyword,
    setSite,
    setSites,
    getSite,
    getEmail,
    setEmail
}